package com.lt.flashcard.view;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.metainfo.ComponentInfo;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zul.Messagebox;

import com.lt.flashcard.Utility;
import com.lt.flashcard.model.service.AAService;
import com.lt.flashcard.model.service.Repository;

public class AdminLogoutCtrl extends SelectorComposer<Component> {

	private static final long serialVersionUID = 1L;

	@Override
	public ComponentInfo doBeforeCompose(Page page, Component parent, ComponentInfo compInfo) {
		AAService srv  = Repository.getInstance().getAAService();
		try {
			srv.doLogout();
			Utility.redirect("/admin_login.zul", false);
			return null;
		}
		catch (Exception e) {
			Messagebox.show(e.getMessage());
		}
		
		return super.doBeforeCompose(page, parent, compInfo);
	}
	
}
